package MallOrderStatistics

import (
	CoreSQL "gitee.com/fotomxq/weeekj_core/v5/core/sql"
	Router2SystemConfig "gitee.com/fotomxq/weeekj_core/v5/router2/system_config"
)

type ArgsCreateOrderStatistics struct {
	//组织ID
	OrgID int64 `db:"org_id" json:"orgID"`
	//用户ID
	UserID int64 `db:"user_id" json:"userID"`
	//订单id
	OrderID int64 `db:"order_id" json:"orderID"`
	//订单金额
	OrderPrice int64 `db:"order_price" json:"orderPrice"`
	//描述
	Des string `db:"des" json:"des"`
	//状态 0 未结清 1 已结清
	Status int64 `db:"status" json:"status"`
	//支付订单id 累计时 不缴费pay_id 为 0
	PayID int64 `db:"pay_id" json:"payID"`
}

// CreateOrderStatistics 创建大客户强制完成订单 累计金额
func CreateOrderStatistics(args *ArgsCreateOrderStatistics) (data FieldsOrderStatistics, errCode string, err error) {
	//创建数据
	err = CoreSQL.CreateOneAndData(Router2SystemConfig.MainDB.DB, "mall_order_statistics",
		"INSERT INTO mall_order_statistics (org_id, user_id,order_id, order_price, des, status, pay_id) VALUES (:org_id, :user_id, :order_id, :order_price, :des, :status, :pay_id)", map[string]interface{}{
			"org_id":      args.OrgID,
			"user_id":     args.UserID,
			"order_id":    args.OrderID,
			"order_price": args.OrderPrice,
			"des":         args.Des,
			"status":      args.Status,
			"pay_id":      args.PayID,
		}, &data)
	if err != nil {
		errCode = "insert"
		return
	}
	//反馈
	return
}
